package com.sharer.last.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 博客显示权限枚举
 *
 * @ClassName BlogShowPermissionEnum
 * @Author WangJin
 * @Date 2023/7/8 10:19
 * @Description
 * @Version 1.0
 */
@Getter
public enum BlogShowPermissionEnum {
    published(1,"公开"),
    Privacy(2,"私有"),
    password(3,"密码");

    private Integer code;
    private String  name;

    private static final Map<Integer, String> STATUS_MAP = new HashMap<>();

    static {
        for (BlogShowPermissionEnum aEnum : BlogShowPermissionEnum.values()) {
            STATUS_MAP.put(aEnum.getCode(), aEnum.getName());
        }
    }

    BlogShowPermissionEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static BlogShowPermissionEnum getEnum(Integer code) {
        for (BlogShowPermissionEnum aEnum : BlogShowPermissionEnum.values()) {
            if (aEnum.getCode().equals(code)) {
                return aEnum;
            }
        }
        return null;
    }

    public static List<Integer> getNotPrivacyCodeList() {
        List<Integer> list = new ArrayList<>();
        for (BlogShowPermissionEnum aEnum : BlogShowPermissionEnum.values()) {
            if (!aEnum.getCode().equals(2)) {
                list.add(aEnum.getCode());
            }
        }
        return list;
    }
}
